﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Web;
using ECCIT.Extension.Weibo_v2.Common;
using OgilvyOne.BLL;
using OgilvyOne.Model;
using OgilvyOne.UKNow.Mobile.Model.MyCalendar;
using OgilvyOne.UKNow.Mobile.Utilities;

namespace OgilvyOne.UKNow.Mobile.APIs.City
{
    using DCity = OgilvyOne.UKNow.Mobile.Model.MyCalendar.City;

  public class GetList : IHttpHandler
    {
      public bool IsReusable
      {
          get { return true; }
      }

      public void ProcessRequest(HttpContext context)
      {
          try
          {
              DictionaryManageBLL bll = new DictionaryManageBLL();
              ArrayList cities = (ArrayList)bll.GetAllCity(Convert.ToInt32(ConfigurationManager.AppSettings["ProviceColumnID"]));
              List<DCity> models = new List<DCity>();
              foreach (DictionaryManageModel city in cities)
              {
                  DCity mCity = new DCity();
                  mCity.cityid = city.Cid;
                  mCity.cnname = city.Cnname;
                  mCity.enname = city.Enname;
                  models.Add((mCity));

              }
              if (models.Count > 0)
              {
                  string s = JsonSerializationHelper.ObjectToJson(models);
                  context.Response.Write(ResultUtility.ReturnResultJson("0", s, "获取城市列表成功"));

              }
          }
          catch (Exception ex)
          {
              context.Response.Write(ResultUtility.ReturnResultJson("-111", "", "获取城市列表失败 Message：" + ex.Message));
              throw;
          }
         

      }

    }
}
